package cc.lucien.demo210423;

import java.util.HashMap;
import java.util.Scanner;

/**
 * 给定一个字符串，请你找出其中不含有重复字符的 **最长子串** 的长度。
 */
public class Demo03 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str = scanner.nextLine();
        System.out.println(longest(str));
    }

    public static int longest(String str){
        int max = 1;
        int count = 0;
        if (str == null || str.equals(""))
            return 1;
        HashMap<Character,Integer> hashMap = new HashMap<>();
        for (int i = 0; i < str.length();){
            Character key = str.charAt(i);
            if (!hashMap.containsKey(key)){
                hashMap.put(key, i);
                count++;
                i++;
            }else {
                max = max > count ? max : count;
                count = 0;
                int value = hashMap.get(key) + 1;
                i = value;
                hashMap.clear();
            }
        }
        return max > count ? max : count;
    }
}
